<#--
List of variables to be passed for this template:
        +- rootPackage
        +- applicationName
        +- classNames
        +- directory
        +- Entities: ArrayList of EntityClass.getAsMap()

            |
            +- imports: imports
            |
            +- name: The name of the class.
            |    |
            |    +- single
            |    +- plural
            |
            +- idColumn: the id column
            |    |
            |    +- field
            |    |    |
            |    |    +- name
            |    |    +- type
            |    |
            |    +- getter
            |    +- setter
            |
            +- columns: ArrayList of columns
            |    |
            |    +- field
            |    +- getter
            |    +- setter

-->
<@pp.dropOutputFile />

<@pp.changeOutputFile name="/development/${directory}/apis/rest/${applicationName?cap_first}RestRepresentation.java" />

package ${rootPackage}.${applicationName}.apis.rest;

import java.io.Writer;

import org.restlet.data.MediaType;
import org.restlet.ext.xstream.XstreamRepresentation;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
import com.thoughtworks.xstream.io.json.JsonWriter;

public class ${applicationName?cap_first}RestRepresentation<T> extends XstreamRepresentation<T>{

	T obj;
	public DiagRestRepresentation(MediaType mediaType, T object) {
		super(mediaType, object);
		this.obj = object;
	}
	@Override
	protected XStream createXstream(MediaType arg0) {

		XStream x = new XStream(new JsonHierarchicalStreamDriver() {
		    public HierarchicalStreamWriter createWriter(Writer writer) {
				return new JsonWriter(writer,new char[0], "", JsonWriter.DROP_ROOT_MODE);
			}
		});
		x.processAnnotations(obj.getClass());
		x.setMode(XStream.NO_REFERENCES);
		return x;
	}
}
